﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// PremiseBO class
    /// </summary>
    public sealed class PremiseBO
    {
        /// <summary>
        /// PremiseDao object
        /// </summary>
        private static readonly PremiseDao Dao = new PremiseDao();

        /// <summary>
        /// Prevents a default instance of the <see cref="PremiseBO"/> class from being created.
        /// </summary>
        private PremiseBO() { }

        /// <summary>
        /// Gets the list.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<Premise> GetList(PremiseFilter filter, string sortType, int startRowIndex, int maxRows)
        {
            return Dao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the list count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public static int GetListCount(PremiseFilter filter)
        {
            return Dao.GetListCount(filter);
        }

        /// <summary>
        /// Gets the premise by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static Premise GetPremiseById(int id)
        {
            return Dao.GetPremiseById(id);
        }

        public static bool AddPremise(Premise premise)
        {
            return Dao.AddPremise(premise);
        }

        public static bool EditPremise(Premise premise)
        {
            return Dao.EditPremise(premise);
        }

        public static void SetPremiseStatus(int premiseId, bool status)
        {
            Dao.SetPremiseStatus(premiseId, status);
        }
    }
}